package com.hainingtong.core.dto;

import com.hainingtong.core.dto.group.DefaultGroup;
import com.hainingtong.core.dto.group.PhoneCodeGroup;
import com.hainingtong.core.dto.group.UsernamePasswordGroup;
import com.hainingtong.core.shiro.token.LoginType;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;


@Data
public class RegisterUserDto {
    @NotNull(groups = DefaultGroup.class, message = "昵称不能为空")
    @Length(groups = DefaultGroup.class, min = 1, max = 20, message = "昵称长度1~20个字符")
    String nickname;

    @NotNull(groups = DefaultGroup.class, message = "账号不能为空")
    @Length(groups = UsernamePasswordGroup.class, min = 4, max = 20, message = "账号只能包含4~20个数字字母下划线")
    @Pattern(groups = PhoneCodeGroup.class, regexp = "1[3-9]\\d{9}", message = "手机号格式不正确")
    String principal;

    @NotNull(groups = PhoneCodeGroup.class, message = "验证码不能为空")
    @NotNull(groups = DefaultGroup.class, message = "密码不能为空")
    @Length(groups = UsernamePasswordGroup.class, min = 6, max = 100, message = "密码长度6~50个字符")
    @Pattern(groups = PhoneCodeGroup.class, regexp = "\\d{4}", message = "验证码是4位数字")
    String credentials;

    @NotNull(groups = DefaultGroup.class, message = "用户类型不能为空")
    @Pattern(groups = UsernamePasswordGroup.class, regexp = LoginType.staticUsernamePassword, message = "用户类型不正确")
    @Pattern(groups = PhoneCodeGroup.class, regexp = LoginType.staticPhoneCode, message = "用户类型不正确")
    String type;
}
